package ar.com.pragmatia.lanacion.data;

import java.util.Vector;

public class Article extends AppData implements Datable {

	public static final String TABLE_NAME = "articles";
	public static final String ID = "";
	public static final String FIELDS[] = { "id", "code", "name", "price",
			"created", "modified", };

	private String code;
	private String name;
	private String price;
	private String created;
	private String modified;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public String getCreated() {
		return created;
	}

	public void setCreated(String created) {
		this.created = created;
	}

	public String getModified() {
		return modified;
	}

	public void setModified(String modified) {
		this.modified = modified;
	}

	public String getStock() {
		TravelingLoad tl = new TravelingLoad();
		Vector<AppData> v = tl.find("WHERE article_id = '" + getId() + "'");
		if (v.size() > 0) {
			return ((TravelingLoad) v.get(0)).getAmount();
		}
		return "0";
	}

	@Override
	public String toString() {
		return code + " - " +name + " - " + getStock();
	}

}
